/**
 * 
 */
package org.estela.classifiers;

import java.util.Arrays;

import org.estela.ml.dataset.Attribute;
import org.estela.ml.dataset.DataSet;



/**
 * @version $Revision$
 * @date May 18, 2006
 * @author <a href="mailto:akantek@nyse.com">Antonio Kantek</a>
 */
public class ClassifierPerformerImpl implements ClassifierPerformer {


	public ClassifierPerformance perform(Classifier classifier, DataSet trainingSet, DataSet testSet, int classAttributeIndex) throws UnsupportedClassAttribute {
		Attribute[] attributes = trainingSet.getAttributes();
		if (!Arrays.equals(attributes, testSet.getAttributes())) {
			throw new IllegalArgumentException("trainingSet and testSet are " +
			"not compatible");
		}
		
		classifier.build(trainingSet, classAttributeIndex);
		ClassifierPerformance performance = new ClassifierPerformance(attributes[classAttributeIndex]);
		performance.setPriors(trainingSet);
		performance.evaluate(classifier, testSet);
		return performance;
	}

	
}
